package videoCourse.sort;

import java.util.Arrays;

public class MyShellSort {

    public static void main(String[] args) {
        int[] arr = new int[]{3,2,5,10,4,6,7,9,8};
        shellSort(arr);
        System.out.println(Arrays.toString(arr));
    }

    private static void shellSort(int[] arr) {
        for(int d = arr.length/2;d>0;d/=2){
            for(int j = d;j<arr.length;j++){
                for(int k = j-d;k>=0;k-=d){
                    if(arr[k] > arr[k+d]){
                        int temp = arr[k];
                        arr[k] = arr[k+d];
                        arr[k+d] = temp;
                    }
                }
            }
        }
    }

}
